package ch11.home;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

class BanNoAscending implements Comparator<Student> {
	// <1
	public int compare(Student s1, Student s2) {
		return s1.ban==s2.ban ? s1.no - s2.no : s1.ban - s2.ban;
	}
	// 1>
}

class Exercise11_07 {
	public static void main(String[] args) {
		ArrayList<Student> list = new ArrayList<Student>();
		list.add(new Student("이자바", 2, 1, 70, 90, 70));
		list.add(new Student("안자바", 2, 2, 60, 100, 80));
		list.add(new Student("홍길동", 1, 3, 100, 100, 100));
		list.add(new Student("남궁성", 1, 1, 90, 70, 80));
		list.add(new Student("김자바", 1, 2, 80, 80, 90));

		Collections.sort(list, new BanNoAscending());
		for(Student student:list) System.out.println(student);
	}
}
/*
남궁성,1,1,90,70,80,240,80.0
김자바,1,2,80,80,90,250,83.3
홍길동,1,3,100,100,100,300,100.0
이자바,2,1,70,90,70,230,76.7
안자바,2,2,60,100,80,240,80.0
*/